package com.safeneeds.linguimana.ser.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.safeneeds.linguimana.dto.StarDataStorePort;
import com.safeneeds.linguimana.entity.PortGlutOnduty;
import com.safeneeds.linguimana.entity.PortGlutStar;
import com.safeneeds.linguimana.entity.dao.IPortGlutDutyDao;
import com.safeneeds.linguimana.entity.dao.IPortGlutStarDao;
import com.safeneeds.linguimana.ser.IBgStarService;
import com.safeneeds.util.base.RetType;
import com.safeneeds.util.date.DateUtil;
import com.safeneeds.util.other.StringUtil;
import com.safeneeds.util.page.PageInfo;
import com.safeneeds.util.page.ser.IPageService;

/**
 * 警星
 * @author ytw
 *
 */
@Service
@Transactional
public class BgStarService implements IBgStarService{
	/**
	 * 获取警星
	 */
	@Resource(name="portGlutStarDao")
	private IPortGlutStarDao portGlutStarDao;
	@Resource(name="pageService")
	private IPageService pageService;
	@Override
	public List<PortGlutStar> getStar() {
		List<PortGlutStar> list=portGlutStarDao.getStar();
		return list;
	}
	@Override
	public PageInfo listStarPage(PageInfo pageInfo,
			StarDataStorePort starDataStorePort) {
		// TODO Auto-generated method stub
		pageInfo = portGlutStarDao.listStarPageDao(pageInfo,starDataStorePort);
		
		pageInfo = pageService.getSQLPageInfo(pageInfo);
		return pageInfo;
	}
	@Override
	public PortGlutStar getportGlutStar(String starId) {
		// TODO Auto-generated method stub
		
		return portGlutStarDao.getStarByStarId(starId);
	}
	@Override
	public RetType deleteStarById(String ids) {
		// TODO Auto-generated method stub
		RetType retType = new RetType();
		portGlutStarDao.deleteStarByIdDao(ids);
		retType.setErrCode(RetType.RET_SUCCESS);
		return retType;
	}
	@Override
	public RetType addOrUpdateStar(PortGlutStar portGlutStar) {
		Date nowdate = new Date();
		portGlutStar.setTime(nowdate);
		// TODO Auto-generated method stub
		if(StringUtil.isEmpty(portGlutStar.getStarId())){
			//新增
			portGlutStarDao.addStarDao(portGlutStar);
		}else{
			//跟新
			portGlutStarDao.saveOrUpdateStarDao(portGlutStar);
		}
		RetType retType = new RetType();
		retType.setErrCode(RetType.RET_SUCCESS);
		return retType;
	}

}
